import request from '@/utils/request'

export default {
    getAllVipsMessage(){
        const req = request({
            method: 'get',
            url: '/dgut/getAllVipMessage'
        })
        return req;
    },
    editOneVips(Message){
        const req = request({
            method: 'put',
            url: '/dgut/updateOneVipMessage',
            params: {
                vid: Message.vid,
                vname: Message.vname,
                vphone: Message.vphone,
                vaddress: Message.vaddress
            }
        })
        return req;
    },
    getOneVips(vid){
        const req = request({
            method: 'get',
            url: '/dgut/getVipMessageById',
            params: {
                vid
            }
        })
        return req;
    },
    deleteOneVips(vid){
        const req = request({
            method: 'delete',
            url: '/dgut/deleteOneVipMessage',
            params: {
                vid
            }
        })
        return req;
    },
    addOneVips(Message) {
        console.log(Message);
        const req = request({
            method: 'post',
            url: '/dgut/addOneVipMessage',
            params: {
                vname: Message.vname,
                vphone: Message.vphone,
                vaddress: Message.vaddress,
                vmoney: Message.vmoney,
                vtype: Message.vtype
            }
        })
        return req;
    },
    search(searchMap) {
        if (searchMap.vid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getVipMessageById',
                params: {
                    vid:searchMap.vid
                }
            })
            return req;
        } else if (searchMap.vname != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getVipMessageByName',
                params: {
                    vname:searchMap.vname
                }
            })
            return req;
        } else if (searchMap.vphone != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getVipMessageByPhone',
                params: {
                    vphone:searchMap.vphone
                }
            })
            return req;
        } else if (searchMap.vaddress != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getVipMessageByAddress',
                params: {
                    vaddress:searchMap.vaddress
                }
            })
            return req;
        } else {
            const req = request({
                method: 'get',
                url: '/dgut/getAllVipMessage'
            })
            return req;
        }
    }
}